<?php

class Application_Model_DbTable_Medicalinfo extends Zend_Db_Table_Abstract
{

    protected $_name = 'MedicalInfo';
    protected $_primary = 'id';
    
	public function getMedicalInfo($userID)
    {
    	$userID = (int)$userID;
    	$row = $this->fetchRow("User_id = " . $userID);
    	if (!$row) {
			throw new Exception("Could not find row $userID");
		}
    	return $row->toArray();
    }
     
	
	public function createMedicalInfo($userID, $visible)
    {
    	$data = array(
    		'Weight' => 0,
    		'Height' => 0,
    		'ViewPermitions' => $visible,
    		'BloodGroup_id'=> 1,
    		'User_id' => $userID,
    	);
    	$this->insert($data);
    }
    
    public function editMedicalInfo($medicalInfoId,$weight,$height,$bloodgroup,$visible)
    {
    	$data = array(
    		'Weight' => $weight,
    		'Height'=> $height,
    		'BloodGroup_id' => $bloodgroup,
    		'ViewPermitions' => $visible,
    	);
    	$this->update($data, 'id = '. (int)$medicalInfoId);    
    }

}

